home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: When to use "->" vs "." when calling Member functions
- Date: Wed, 17 Jan 1996 09:38:01 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <30FCB569.41C67EA6@intellektik.informatik.th-darmstadt.de>
- References: <4dhea1$6v8@ornews.intel.com>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (X11; I; SunOS 4.1.3 sun4m)
-
- Thurman Miller wrote:
- >
- > I'm confused, so please no harsh remarks :)
- >
- > If I've got:
- >
- > class Cfoo
- > {
- > something * getptr();
- > somethingelse* m_other;
- > }
- >
- > something * foo::getptr()
- > {
- > return m_other;
- > }
- >
- > Now...if I'm in another class....
- >
- > Cfoo foo;
- > somethingelse* = foo.getptr();
- >
- > why doesn't the following work?
- >
- > somethingelse* = foo->getptr();
- >
- > I get compile error about no "->" overloaded operator....
- >
- > Can someone point out the obvious when I use one notation over
- > another?
- >
-
- If you want to use 'foo.f' where 'f' is some member of a class,
- 'foo' must be an instance or reference to that class. If 'foo'
- is a pointer to a class you must use 'foo->f' to access the member 'f'.
-
- Enno
-